package org.carl.grpc.cloud.service.a.service

import io.grpc.stub.StreamObserver
import net.devh.boot.grpc.server.service.GrpcService
import org.carl.grpc.cloud.model.demo.HelloReply
import org.carl.grpc.cloud.model.demo.HelloRequest
import org.carl.grpc.cloud.model.demo.SimpleGrpc
import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 * email carl.chen@bk.ru
 * @Author: 陈青松
 * @Date: 2019/4/12 0:22
 */
@GrpcService
class GrpcServerService : SimpleGrpc.SimpleImplBase() {
    companion object {
        val LOG: Logger = LoggerFactory.getLogger(this::class.java)
    }

    override fun sayHello(
            req: HelloRequest?,
            responseObserver: StreamObserver<HelloReply>?
    ) {
        val reply = HelloReply.newBuilder().setMessage("Hello ==> " + req!!.getName()).build()
        responseObserver!!.onNext(reply)
        responseObserver!!.onCompleted()
    }
}